<?php
	require_once 'sql.utils.php';
	class sameBook{
		protected $_query;
		protected $_sql_utils;
		protected $_result;
		protected $_header;
		protected $_divClass;
		function __construct($query,$header,$divClass){
			$this->_query = $query;
			$this->_header = $header;
			$this->_sql_utils = new SqlUtils();
			$this->_result = $this->_sql_utils->getRows($this->_query);
			$this->_divClass = $divClass;
		}
		function display(){
			echo '<div class= "'.$this->_divClass.'">';
			echo '<div class = "same-book-header">'.$this->_header.'</div>';
			for ($i=0; $i < count($this->_result); $i++) {
				$img =  'images/book/'.$this->_result[$i]['bookImage'];
				$alt = $this->_result[$i]['bookName'];
				$bookId = $this->_result[$i]['bookId'];
				echo '<a onclick="getBook('.$bookId.')"'.$this->_result[$i]['bookId'].'"><img alt= '.$alt.' src= '.$img.' /></a>';
			}
			echo '</div>';
		}
	}
?>